//
//  WKSecurityViewController.m
//  ourToken
//
//  Created by wakeup on 2018/5/31.
//  Copyright © 2018年 ourtoken. All rights reserved.
//

#import "WKSecurityViewController.h"
#import "WKBaseHeader.h"

@interface WKSecurityViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *dataArray;

@end

@implementation WKSecurityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavigationView];
    [self layoutUI];
    self.view.backgroundColor = [UIColor whiteColor];
    self.dataArray = @[@"修改密码",@"更换手机号",@"更换邮箱"];
}

- (void)setNavigationView {
    [super setNavigationView];
    self.navigationView.topTitleLabel.text = @"安全中心";
}

- (void)layoutUI {
    [self.view addSubview:self.tableView];
}

#pragma mark - UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SecurityCell"];
    cell.textLabel.text = self.dataArray[indexPath.row];
    cell.textLabel.font = AppManager.tableTextFont;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        WKChangePasswordViewController *changePassword = [[WKChangePasswordViewController alloc] init];
        [self.navigationController pushViewController:changePassword animated:YES];
    }
    else if (indexPath.row == 1) {
        WKChangePhoneNumberViewController *changePhoneNumber = [[WKChangePhoneNumberViewController alloc] init];
        [self.navigationController pushViewController:changePhoneNumber animated:YES];
    }
    else if (indexPath.row == 2) {
        WKChangeMailboxViewController *changeMailbox = [[WKChangeMailboxViewController alloc] init];
        [self.navigationController pushViewController:changeMailbox animated:YES];
    }
}

- (UITableView *)tableView {
    if (_tableView == nil) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, AppManager.navigationHeight, AppManager.width, AppManager.height-AppManager.navigationHeight) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = [[UIView alloc] init];
        _tableView.backgroundColor = AppManager.tableBackColor;
        _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, AppManager.width, 10)];
    }
    return _tableView;
}

@end
